﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minmum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="format-detection" content="telephone=no, email=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <script src="js/vue.min.js"></script>
</head>
<body>
<div id="app">
    <div>
        <router-link to="/home">Go to Home</router-link>
        <router-link to="/about">Go to About</router-link>
    </div>
    <router-view></router-view>
</div>


<script src="js/vue-router.min.js"></script>

<script type="text/javascript">

    const Home = Vue.extend({
        template: '<div><h1>Home</h1><p>{{msg}}</p></div>',
        data: function() {
            return {
                msg: 'Hello, vue router!'
            }
        }
    });
    const About = Vue.extend({
        template: '<div><h1>About</h1><p>This is the tutorial about vue-router.</p></div>'
    });
    const router = new VueRouter({
        routes: [
            { path: '/home', component: Home },
            { path: '/about', component: About },
            { path: '/', component: Home } //设置默认路径
        ]
    });

    const vm = new Vue({router: router}).$mount('#app');

</script>
</body>
</html>